//
//  user.m
//  KouDaiMaster
//
//  Created by 范智渊 on 2018/4/12.
//  Copyright © 2018年 zzgk. All rights reserved.
//

#import "User.h"
#import "HttpEngine.h"
#import "KDMDataInterface.h"
#import "userManagerTool.h"
#import "KDMUserData.h"
@implementation User

-(instancetype)init {
    self = [super init];
    if (self) {
        self.mUserName = @"";
//        self.mMemberGrade = @"";
//        self.mBalance = @"";
//        self.mScore = @"";
        self.mIsLogin = NO;
        self.mIsThirdLogin = NO;
        self.portraitURL = @"";
        self.mIsAutoLogin = YES;
        self.mPassword = @"";
        self.thirdType = -1;
        self.accessToken = @"";

    }
    return self;

}
- (void)save{
        for (User* _i in [[self class] allObjects]) {
            [_i deleteObject];
        }
        [super save];
    }


- (void)getUserInfoFromServerWithSuccess:(void (^)(void))successBlock andError:(void (^)(void))errorBlock {

    [kHttpEngine POST:URL_account_viewMemberInfo parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {

        KDMUserData *userData = [KDMUserData mj_objectWithKeyValues:responseObject];


//        if (userData.result.intValue == 1) {
//
////            [[NSUserDefaults standardUserDefaults]setObject:userData.memberId forKey:ZuiyoujiUserId];//当前用户的id
////            [[NSUserDefaults standardUserDefaults]setObject:userData.nick forKey:ZuiyoujiNickName];
////            [[NSUserDefaults standardUserDefaults]setObject:userData.logName forKey:ZuiyoujiLoginName];
//            [[NSUserDefaults standardUserDefaults]setObject:userData.gender forKey:ZuiyoujiUserSex];//当前用户的性别
//            [[NSUserDefaults standardUserDefaults]setObject:userData.portraitUrl forKey:ZuiyoujiUserHeader];//用户头像
//            [[NSUserDefaults standardUserDefaults] synchronize];
//
//            [[NSNotificationCenter defaultCenter] postNotificationName:@"ZUIYOULOGINSUCCESS" object:nil];
//
//            [UserInfoManager getUserInfo].isBinding=NO;
//
//            if (userData.mobile.length>0) {//表示绑定过
//                [UserInfoManager getUserInfo].isBinding=YES;
//            }
//
//            successBlock();
//        }else{
//            errorBlock();
//        }
//
    } failure:^void(NSURLSessionDataTask * task, NSError * error) {
        errorBlock();
    }];
}
@end
